<?php
/**
 * Created by PhpStorm.
 * User: sunshubo
 * Date: 2017/9/20
 * Time: 22:01
 */

class Logout_model extends CI_Model
{
    function logout()
    {
        $cookie = $this->input->cookie()['_wsxt'];
//        var_dump($cookie['_wsxt']);
        $sql = /** @lang text */
            "UPDATE ws_user SET expire='0' WHERE token='$cookie'";

        $query = $this->db->query($sql);
        if ($query) {
            $cookie = array(
                'name' => '_wsxt',
                'value' => '',
                'expire' => 0,
            );
            $this->input->set_cookie($cookie);

            return json_encode(array('result' => SUCCESS, 'msg' => '退出成功！'));
        }
        return json_encode(array('result' => ERROR, 'msg' => '系统故障，请联系管理员！'));
    }
}